package com.miyu.system.service.sys.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import com.alibaba.fastjson2.JSONObject;
import com.miyu.common.utils.http.HttpUtils;
import com.miyu.common.utils.magic.GetBeanUtil;
import com.miyu.system.dao.book.BookMainDao;
import com.miyu.system.pojo.system.SysTask;
import com.miyu.system.service.sys.TaskJobService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * 构建任务工作
 * @author longm
 * @date 2022/12/31
 */
public class BuildTaskJob implements Job {
    TaskJobService taskJob = (TaskJobService) GetBeanUtil.getBeanByClass(TaskJobService.class);
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        SysTask sysTask = taskJob.getSysTaskById(jobExecutionContext.getJobDetail().getKey().getName());
        String url = sysTask.getTaskUrl();
        String taskParam = sysTask.getTaskParam();
        String taskType = sysTask.getTaskType();
        if(taskType.equals("POST")){
            //执行
            HttpUtils.post(url, taskParam);
        }else{
            //执行
            HttpUtils.get(url,10000,"");
        }


    }
}
